package cn.xy

import scala.collection.mutable.ListBuffer

/**
  * Created by xiaoyuan on 2017/11/8.
  */
object Test {

  class Obj(st:String,v:Float){
    //全网非全网
    var site:String = st
    //数值
    var value:Float = v
  }

  def main(args: Array[String]): Unit = {

    println("ok")
    var a = new Obj("aa",12.3f);
    var b= new Obj("aa",12.2f);
    var c = new Obj("aa",12.25f);
    var d = new Obj("ac",12.85f);
    var e= new Obj("ac",12.8f);
    var f = new Obj("aa",12.9f);
    //构造一个表（execl）
    var list = List(a,b,c,d,e,f)

    var map = Map[String,List[Obj]]()
    //按全网非全网放入map
    list.foreach(x=>{
      if(map.contains(x.site)){
        var temp = map.get(x.site)
        map+=(x.site->(temp.get:+x))
        //print("a");
      }else{
        map+=(x.site->List[Obj](x))
      }
    })
    //遍历map的value并将其排序
    for( (k,v)<-map ){
      map+=(k->v.sortWith(_.value>_.value))
    }
    //按key值增就行了
    //。。。。。
    var result = map.toList.sortWith(_._1>_._1)

    print(result)
  }
}
